from sqlalchemy import select, func
from sqlalchemy.ext.asyncio import AsyncSession
from app.models import EvaluationItemScore


async def compute_evaluation_total(session: AsyncSession, evaluation_id: str) -> float:
    stmt = select(func.sum(EvaluationItemScore.score_value)).where(EvaluationItemScore.evaluation_id == evaluation_id)
    result = await session.execute(stmt)
    total = result.scalar() or 0.0
    return float(total)